let id = new URLSearchParams(location.search).get('id')

// 评论列表显示
function commont(){
  $.ajax({
    type: 'get',
    url: 'http://localhost:8888/api/articles/' + id + '/comments',
    success: function (res) {
      if (res.status === 0) {
        let html = template('show',res)
        $('#comment-list').html(html)
      }
    }
  })
}
commont()

   // 发表评论
   $('#comment-form').submit(function (e) {
    e.preventDefault()
    let fd = $(this).serialize()
    $.ajax({
      type: 'post',
      url: 'http://localhost:8888/api/articles/' + id + '/comments',
      data: fd,
      success: function (res) {
        if (res.status === 0) {
          // 发表评论成功
          layer.msg(res.message)
          $('#comment-form').get(0).reset()
          commont()
        }
      }
    })
  })